package com.review.Test.Master_Worker.reference;

import java.util.ArrayList;
import java.util.List;

public class A {
	
	private String name = new String();
	private Integer age = new Integer(24);
	private List<String> info = new ArrayList<>();
	
	
	
	@Override
	public String toString() {
		return "A [name=" + name + ", age=" + age + ", info=" + info + "]";
	}

	public A(B b){
		b.setAge(this.age);
		b.setName(this.name);
		b.setInfo(this.info);
	}
	

	public static void main(String[] args) throws InterruptedException {
		B b = new B();
		System.out.println(b);
		A a = new A(b);
		System.out.println(a);
		System.out.println(b);
		new Thread(b).start();
		
		Thread.sleep(2000);
		System.out.println(a);
		System.out.println(b);
		
	}

}

class B implements Runnable{
	private String name;
	private Integer age;
	private List<String> info;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getAge() {
		return age;
	}
	public void setAge(Integer age) {
		this.age = age;
	}
	public List<String> getInfo() {
		return info;
	}
	public void setInfo(List<String> info) {
		this.info = info;
	}
	@Override
	public String toString() {
		return "B [name=" + name + ", age=" + age + ", info=" + info + "]";
	}
	@Override
	public void run() {
		info.add("123");
		
	}
}
